package com.cangxuan.manage.controller;

import com.cangxuan.manage.annotation.Check;
import com.cangxuan.manage.annotation.check.Max;
import com.cangxuan.manage.annotation.check.NotNull;
import com.cangxuan.manage.bean.Page;
import com.cangxuan.manage.entity.UserAmountRecord;
import com.cangxuan.manage.service.IUserAmountRecordService;
import io.swagger.annotations.*;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 游星宇
 * 用户流水相关控制器
 */
@Api(tags = "用户流水相关接口")
@RestController
@RequestMapping("useramountrecord")
public class UserAmountRecordController extends BaseController {
    IUserAmountRecordService iUserAmountRecordService;
    @Autowired
    public void setiUserAmountRecordService(IUserAmountRecordService iUserAmountRecordService) {
        this.iUserAmountRecordService = iUserAmountRecordService;
    }
    /**
     * 根据ID获取用户流水
     * @param
     * @return
     */


    @Data
    @ApiModel("用户流水分页查询body")
    public static class UserAmountRecordPage{
        @ApiModelProperty("页码，从1开始")
        @NotNull(message = "请传递pageIndex")
        Integer pageIndex;
        @ApiModelProperty("页大小，就是每页查询的数量，最大为50条")
        @Max(value = 50, message = "pageSize不能大于50")
        Integer pageSize = 10;
        @ApiModelProperty("用户id")
        Integer userId;
    }
    /**
     * 分页获取用户流水
     * @param
     * @return
     */
    @PostMapping
    @ApiOperation("藏品分页查询")
    public Object page(@Check @RequestBody UserAmountRecordController.UserAmountRecordPage userAmountRecordPage) {
        Page<UserAmountRecord> goodsPage = iUserAmountRecordService.page(userAmountRecordPage.getPageIndex(),
                userAmountRecordPage.getPageSize(),
                userAmountRecordPage.getUserId()
        );
        return success(goodsPage);
    }

    @GetMapping("get/{userId}")
    @ApiOperation("根据用户ID查询用户流水")
    public Object get(@ApiParam("userId") @PathVariable Integer userId) {
        return success("请求成功", iUserAmountRecordService.select(userId));
    }


}
